home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / wtj007.zip / BAKER.ZIP / NETCAPS.C < prev    next >
Text File  |  1992-07-24  |  8KB  |  220 lines

  1. #include "windows.h"
  2. #include "winnet.h"
  3.  
  4. WORD NetCaps[11];
  5.  
  6. char *Net_Type[] = { "None","MSNet","LanMan","NetWare","Vines","10NET",
  7.                     "Locus","Sun PC NFS","LANStep","9TILES","Lantastic",
  8.                     "AS400"};
  9.  
  10. /* Get Network Capabilities for use later */
  11. static void PASCAL NetGetCapability()
  12. {
  13.     WORD    i;
  14.     for (i = 1; i <= 11; i++)
  15.         if ( i != 4)
  16.             NetCaps[i] = WNetGetCaps(i);
  17. }
  18.  
  19. /*    NetCapsDlgProc(HWND, unsigned, WORD, LONG)
  20.  *
  21.  *    Processes messages for "NetCaps" dialog box
  22.  *    Messages:
  23.  *        WM_INITDIALOG - initialize dialog box
  24.  *        WM_COMMAND    - Input received
  25.  *    No initialization is needed for this particular dialog box, but TRUE
  26.  *    must be returned to Windows.
  27.  *
  28.  *    Wait for user to click on "Ok" button, then close the dialog box.
  29.  */
  30. BOOL FAR PASCAL NetCapsDlgProc(HWND hDlg, unsigned message, WORD wParam,
  31.                                 LONG lParam)
  32. {
  33.     WORD nIndex;
  34.  
  35.     switch (message) {
  36.  
  37.     case WM_INITDIALOG:           /* message: initialize dialog box */
  38.  
  39.         NetGetCapability();        /* get Network Capabilities */
  40.  
  41.        /* query net version number (SPEC_VERSION) == NetCaps[1] */
  42.         wsprintf((LPSTR) szBuffer, "%u.%u",  HIBYTE(NetCaps[1],LOBYTE(NetCaps[3]) );
  43.         SendDlgItemMessage(hDlg, IDD_DRVVER, WM_SETTEXT, NULL, (LONG)(LPSTR) szBuffer);
  44.  
  45.        /* query for Username support (USER) == NetCaps[4] */
  46.         if (NetCaps[4] & 1 )
  47.             lstrcpy(szBuffer, "Supported");
  48.         else 
  49.             lstrcpy(szBuffer, "Unsupported");
  50.         SendDlgItemMessage(hDlg, IDD_USER, WM_SETTEXT, NULL, (LONG)(LPSTR) szBuffer);
  51.  
  52.        /* query connection support mask (CONNECTION) == NetCaps[6] */
  53.         if ( NetCaps[6]) {
  54.             if (NetCaps[6] & 0x0001) {    /* AddConnection */ 
  55.                 lstrcpy(szBuffer, "Add");
  56.                 SendDlgItemMessage(hDlg, IDD_CONNECTIONS, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  57.             }
  58.             if (NetCaps[6] & 0x0002) {    /* CancelConnection */ 
  59.                 lstrcpy(szBuffer, "Cancel");
  60.                 SendDlgItemMessage(hDlg, IDD_CONNECTIONS, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  61.             }
  62.             if (NetCaps[6] & 0x0004) {    /* GetConnection */ 
  63.                 lstrcpy(szBuffer, "Get");
  64.                 SendDlgItemMessage(hDlg, IDD_CONNECTIONS, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  65.             }
  66.             if (NetCaps[6] & 0x0008) {    /* AutoConnection */ 
  67.                 lstrcpy(szBuffer, "AutoCon");
  68.                 SendDlgItemMessage(hDlg, IDD_CONNECTIONS, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  69.             }
  70.             if (NetCaps[6] & 0x0010) {    /* BrowseDialog for connections */ 
  71.                 lstrcpy(szBuffer, "Browse");
  72.                 SendDlgItemMessage(hDlg, IDD_CONNECTIONS, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  73.             }
  74.             if (NetCaps[6] & 0x0020) {    /* RestoreConnection */ 
  75.                 lstrcpy(szBuffer, "Restore");
  76.                 SendDlgItemMessage(hDlg, IDD_CONNECTIONS, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  77.             }
  78.         }
  79.         else {
  80.             lstrcpy(szBuffer, "Not Supported");
  81.             SendDlgItemMessage(hDlg, IDD_CONNECTIONS, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  82.         }
  83.  
  84.        /* query printing support (PRINTING) == NetCaps[7] */
  85.         if ( NetCaps[7] ) {
  86.             if (NetCaps[7] & 0x0002) {
  87.                 lstrcpy(szBuffer, "Open Job");
  88.                 SendDlgItemMessage(hDlg, IDD_PRINTING, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  89.             }
  90.             if (NetCaps[7] & 0x0004) {
  91.                 lstrcpy(szBuffer, "Close Job");
  92.                 SendDlgItemMessage(hDlg, IDD_PRINTING, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  93.             }
  94.             if (NetCaps[7] & 0x0010) {
  95.                 lstrcpy(szBuffer, "Hold Job");
  96.                 SendDlgItemMessage(hDlg, IDD_PRINTING, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  97.             }
  98.             if (NetCaps[7] & 0x0020) {
  99.                 lstrcpy(szBuffer, "Release Job");
  100.                 SendDlgItemMessage(hDlg, IDD_PRINTING, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  101.             }
  102.             if (NetCaps[7] & 0x0040) {
  103.                 lstrcpy(szBuffer, "Cancel Job");
  104.                 SendDlgItemMessage(hDlg, IDD_PRINTING, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  105.             }
  106.             if (NetCaps[7] & 0x0080) {
  107.                 lstrcpy(szBuffer, "Set Job Copies");
  108.                 SendDlgItemMessage(hDlg, IDD_PRINTING, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  109.             }
  110.             if (NetCaps[7] & 0x0100) {
  111.                 lstrcpy(szBuffer, "Watch Queue");
  112.                 SendDlgItemMessage(hDlg, IDD_PRINTING, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  113.             }
  114.             if (NetCaps[7] & 0x0200) {
  115.                 lstrcpy(szBuffer, "UnWatch Queue");
  116.                 SendDlgItemMessage(hDlg, IDD_PRINTING, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  117.             }
  118.             if (NetCaps[7] & 0x0400) {
  119.                 lstrcpy(szBuffer, "Lock Queue Data");
  120.                 SendDlgItemMessage(hDlg, IDD_PRINTING, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  121.             }
  122.             if (NetCaps[7] & 0x0800) {
  123.                 lstrcpy(szBuffer, "Unlock Queue Data");
  124.                 SendDlgItemMessage(hDlg, IDD_PRINTING, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  125.             }
  126.             if (NetCaps[7] & 0x1000) {
  127.                 lstrcpy(szBuffer, "Change Message");
  128.                 SendDlgItemMessage(hDlg, IDD_PRINTING, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  129.             }
  130.             if (NetCaps[7] & 0x2000) {
  131.                 lstrcpy(szBuffer, "Abort Job");
  132.                 SendDlgItemMessage(hDlg, IDD_PRINTING, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  133.             }
  134.             if (NetCaps[7] & 0x8000) {
  135.                 lstrcpy(szBuffer, "Write Job");
  136.                 SendDlgItemMessage(hDlg, IDD_PRINTING, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  137.             }
  138.         }
  139.         else {
  140.             lstrcpy(szBuffer, "Not supported");
  141.             SendDlgItemMessage(hDlg, IDD_PRINTING, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  142.         }
  143.  
  144.        /* query dialog support (DIALOG) == NetCaps[8] */
  145.         if ( NetCaps[8] ) {        /* which dialog boxes are supported */
  146.         {
  147.             if (NetCaps[8] & 0x0001) {
  148.                 lstrcpy(szBuffer, "Device Mode");
  149.                 SendDlgItemMessage(hDlg, IDD_DIALOG, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  150.             }
  151.             if (NetCaps[8] & 0x0002) {
  152.                 lstrcpy(szBuffer, "Browse Dialog");
  153.                 SendDlgItemMessage(hDlg, IDD_DIALOG, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  154.             }
  155.             if (NetCaps[8] & 0x0004) {
  156.                 lstrcpy(szBuffer, "Connect Dialog");
  157.                 SendDlgItemMessage(hDlg, IDD_DIALOG, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  158.             }
  159.             if (NetCaps[8] & 0x0008) {
  160.                 lstrcpy(szBuffer, "Disconnect Dialog");
  161.                 SendDlgItemMessage(hDlg, IDD_DIALOG, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  162.             }
  163.             if (NetCaps[8] & 0x0010) {
  164.                 lstrcpy(szBuffer, "View Queue Dialog");
  165.                 SendDlgItemMessage(hDlg, IDD_DIALOG, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  166.             }
  167.             if (NetCaps[8] & 0x0020) {
  168.                 lstrcpy(szBuffer, "Property Dialog");
  169.                 SendDlgItemMessage(hDlg, IDD_DIALOG, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  170.             }
  171.             if (NetCaps[8] & 0x0040) {
  172.                 lstrcpy(szBuffer, "Connection Dialog");
  173.                 SendDlgItemMessage(hDlg, IDD_DIALOG, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  174.             }
  175.         }
  176.         else {
  177.             lstrcpy(szBuffer, "Not supported\n");
  178.             SendDlgItemMessage(hDlg, IDD_DIALOG, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  179.         }
  180.  
  181. #define IDD_ADMIN    IDD_CONNECTIONS
  182.        /* query administrative support (ADMIN) = NetCaps[9] */
  183.         if ( NetCaps[9] ) {
  184.             if ( NetCaps[9] & 0x0001 ) {
  185.                 lstrcpy(szBuffer, "Get Directory Type");
  186.                 SendDlgItemMessage(hDlg, IDD_ADMIN, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  187.             }
  188.             if ( NetCaps[9] & 0x0002 ) {
  189.                 lstrcpy(szBuffer, "Dir Notify");
  190.                 SendDlgItemMessage(hDlg, IDD_ADMIN, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  191.             }
  192.             if ( NetCaps[9] & 0x0004 ) {
  193.                 lstrcpy(szBuffer, "Long Names");
  194.                 SendDlgItemMessage(hDlg, IDD_ADMIN, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  195.             }
  196.         }
  197.         else {
  198.             lstrcpy(szBuffer, " ADMIN Not supported\n");
  199.             SendDlgItemMessage(hDlg, IDD_DIALOG, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  200.         }
  201.  
  202.        /* query print manager support (PRINTMGREXT) == NetCaps[11] */
  203.         if ( NetCaps[11] ) {
  204.             wsprintf((LPSTR) szBuffer, "Print Manager %u.%u", HIBYTE(NetCaps[11]), LOBYTE(NetCaps[11]));
  205.             SendDlgItemMessage(hDlg, IDD_PRINTING, LB_ADDSTRING, NULL, (LONG)(LPSTR) szBuffer);
  206.         }
  207.  
  208.         return (TRUE);
  209.         break;
  210.  
  211.     case WM_COMMAND:              /* message: received a command */
  212.         if (wParam == IDOK) {          /* "OK" box selected?         */
  213.         EndDialog(hDlg, TRUE);          /* Exits the dialog box         */
  214.         return (TRUE);
  215.         }
  216.         break;
  217.     }
  218.     return (FALSE);                  /* Didn't process a message    */
  219. }
  220.